package com.ruoyi.web.controller.process;

import java.util.List;

import com.ruoyi.common.annotation.PropertyInject;
import com.ruoyi.common.enums.InjectType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.process.domain.WorkArtiseeding;
import com.ruoyi.process.service.IWorkArtiseedingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 人工播种Controller
 *
 * @author ruoyi
 * @date 2021-07-12
 */
@RestController
@RequestMapping("/process/artiseeding")
public class WorkArtiseedingController extends BaseController
{
    @Autowired
    private IWorkArtiseedingService workArtiseedingService;

    /**
     * 查询人工播种列表
     */
    @PreAuthorize("@ss.hasPermi('process:artiseeding:list')")
    @GetMapping("/list")
    public TableDataInfo list(WorkArtiseeding workArtiseeding)
    {
        startPage();
        List<WorkArtiseeding> list = workArtiseedingService.selectWorkArtiseedingList(workArtiseeding);
        return getDataTable(list);
    }

    /**
     * 导出人工播种列表
     */
    @PreAuthorize("@ss.hasPermi('process:artiseeding:export')")
    @Log(title = "人工播种", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WorkArtiseeding workArtiseeding)
    {
        List<WorkArtiseeding> list = workArtiseedingService.selectWorkArtiseedingList(workArtiseeding);
        ExcelUtil<WorkArtiseeding> util = new ExcelUtil<WorkArtiseeding>(WorkArtiseeding.class);
        return util.exportExcel(list, "人工播种数据");
    }

    /**
     * 获取人工播种详细信息
     */
    @PreAuthorize("@ss.hasPermi('process:artiseeding:query')")
    @GetMapping(value = "/{workArtiseedingId}")
    public AjaxResult getInfo(@PathVariable("workArtiseedingId") Long workArtiseedingId)
    {
        return AjaxResult.success(workArtiseedingService.selectWorkArtiseedingById(workArtiseedingId));
    }

    /**
     * 新增人工播种
     */
    @PreAuthorize("@ss.hasPermi('process:artiseeding:add')")
    @Log(title = "人工播种", businessType = BusinessType.INSERT)
    @PostMapping
    @PropertyInject(type= InjectType.Insert)
    public AjaxResult add(@RequestBody WorkArtiseeding workArtiseeding)
    {
        return toAjax(workArtiseedingService.insertWorkArtiseeding(workArtiseeding));
    }

    /**
     * 修改人工播种
     */
    @PreAuthorize("@ss.hasPermi('process:artiseeding:edit')")
    @Log(title = "人工播种", businessType = BusinessType.UPDATE)
    @PutMapping
    @PropertyInject(type= InjectType.Update)
    public AjaxResult edit(@RequestBody WorkArtiseeding workArtiseeding)
    {
        return toAjax(workArtiseedingService.updateWorkArtiseeding(workArtiseeding));
    }

    /**
     * 删除人工播种
     */
    @PreAuthorize("@ss.hasPermi('process:artiseeding:remove')")
    @Log(title = "人工播种", businessType = BusinessType.DELETE)
	@DeleteMapping("/{workArtiseedingIds}")
    public AjaxResult remove(@PathVariable Long[] workArtiseedingIds)
    {
        return toAjax(workArtiseedingService.deleteWorkArtiseedingByIds(workArtiseedingIds));
    }
}
